def is_valid(s):
    cvetka = []
    ing = {")": "(", "}": "{", "]": "[", ">": "<"}
    for alina in s:
        if alina in ing.values():
           cvetka.append(alina)
        elif alina in ing:
            if not cvetka or cvetka.pop() != ing[alina]:
                return False
    return not cvetka


clovo = input("Введите скобочную последовательность:")
print(is_valid(clovo))
